#include <pthread.h>
#include "ebm_env.h"
#include "ebm_msg.h"
#include "ebm_passback.h"
#include "ebm_task.h"



static void *rtp_task(void *parm)
{
	while(1)
	{
		rtp_net_loop();
	}
	rtp_net_stop();
	return 0;
}

static void creat_rtp_pthread(void)
{
	pthread_t threads;
	int rc;
	long t=0;
	rc = pthread_create(&threads, NULL, rtp_task, (void *)t);
	if (rc){
		printf("ERROR; return code from pthread_create() is %d\n", rc);
		exit(-1);
	}
}

void creat_command_pthread(void)
{
	pthread_t threads;
	long t=0;
	if (pthread_create(&threads, NULL, command_tast, (void *)t)){
		puts(__func__);
		exit(-1);
	}
}


static void creat_passback_pthread(void)
{
	pthread_t threads;
	int rc;
	long t=0;
	rc = pthread_create(&threads, NULL, passback_task, (void *)t);
	if (rc){
		printf("ERROR; return code from pthread_create() is %d\n", rc);
		exit(-1);
	}
}


void *ebm_task(void *param)
{
	//unsigned int cnt=0;
	creat_rtp_pthread();
	sys_log("系统初始化完成");
	creat_command_pthread();
	creat_passback_pthread();	
	while(1)
	{	
		//if((cnt++)%50 == 0)
		//	nstar_adt_watchdog_feed();
		ebm_play_manage_loop();
		usleep(10*1000);
	}
	return 0;
}



#include "zcx_msg.h"
#include "nstar_http.h"
#include "nstar_hcf4051.h"


const char* visit_ebm_sta(void)
{
	static char buf[40];
	unsigned char ch_sta= visit_ch_sel();
	switch(ch_sta){
		case CH1_NB_DVB:
			snprintf(buf, 40, "IP，%s", visit_pg_net_info());
			break;
		case CH1_NB_FM:
			snprintf(buf, 40, "FM，%s", visit_fm_sta_str());
			break;
		default:
			snprintf(buf, 40, "待机中");
			break;
		
	}
	return buf;
}





